<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  	<style type="text/css">
  		.b{
  			font-family: 黑体;
  			color: red;
  		}
  	</style>
    <script type="text/javascript" src="<%=path %>/js/jquery-1.6.4.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$('#s1').text("what");
			
			/*
			var s = 
			{
				"username": "sunchen",
				"age": 20,
				"arr":
				[
					{"a1": "111", "a2": "111111"},
					{"a1": "222", "a2": "222222"}
				]
			};
			*/
			
			/*
			var t = s.arr;
			for(i in t){
				alert(t[i].a1);
			}
			*/
			
			/*
			var t = s.arr;
			$.each(t, function(i,n){
				alert(n.a1);
			});
			*/
			
			/*
			var t = s.arr;
			for(var i=0; i<t.length; i++){
				alert(t[i].a1);
			}
			*/
			/*
			var i = s.arr;
			alert(i[0].a1);
			*/
			
			$.ajax({
				type: "GET",
				url: "<%=path %>/ajax?method=getSessionByStaff&ename=sunchen",
				dataType: "json",
				success : function(data, textStatus){
					var unread_array = data.unread;
					if(unread_array != null){
						$.each(unread_array, function(i,node){
							$('#d1').append(makeSessionNode(node.id, node.topic, node.isRead, node.joinTime));
						});
					}
					var read_array = data.read;
					if(read_array != null){
						$.each(read_array, function(i,node){
							$('#d1').append(makeSessionNode(node.id, node.topic, node.isRead, node.joinTime));
						});
					}
				},
				error : function(){
					alert("请求失败");
				}
			});
			
			function makeSessionNode(id, topic, isReadS, joinTime){
				return $('<div id="' + id + '" class="b">' + topic +'     '+ joinTime + '</div>');
			}
			
			
		});
	</script>
  </head>
  
  <body>
    孙晨<br/>
    <span id="s1"></span>
    <div id="d1">
    </div>
  </body>
</html>
